package com.far.game.xiuzhen.common.utils;

import cn.hutool.core.util.ObjectUtil;

public class Optional<M> {

    private M val;

    public Optional(M data) {
        this.val = data;
    }

    public Optional<M> orElse(M data){
        if(ObjectUtil.isEmpty(val)){
            this.val = data;
        }
        return this;
    }


    public M getVal() {
        return val;
    }

    public void setVal(M val) {
        this.val = val;
    }

    public static <T> Optional<T> of(T object){
        return new Optional<T>(object);
    }


}
